<?php 
include_once('includes.php'); 	

$where=" where  status=2  ";
//paging--------------
include_once('includes/paging.class.php');

$q_str = $_SERVER['QUERY_STRING'];
if(isset($_GET['page']))
{
  $q_str = str_replace('page='.$_GET['page'],'',$_SERVER['QUERY_STRING']);    
}
$sql = "select count(*) as total from  highlights left join matchs on highlights.match_id = matchs.id left join competition on matchs.competition_id = competition.id   $where ";
$r=db_fetch_one($sql);
$total=$r->total;

$paging = new Paging();

$paging->assign ( 'highlights?'.$q_str ,  $total , 20 );
$limit = ' Limit '.$paging->sql_limit();

//-------------------

$sql = "select  highlights.id as hid, highlights.* ,matchs.*, competition.name as cname, competition.id as cid, competition.classicon as cicon from   highlights left join matchs on highlights.match_id = matchs.id left join competition on matchs.competition_id = competition.id  $where  order by matchs.kick_off desc $limit";
$matchs=db_fetch_all($sql);
?>
<?php include_once('includes/header.php'); 	 ?>

<?php

if(count($matchs)>0) 
{
?>

<div class="cbox clearfix">
	<div class="content">
		<ul class="matchs">
	<?php 
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	
		list($team1, $team2 ) = split('-',$match->versus);
		$team1 = trim($team1);
		$team2 = trim($team2);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $team1." ".$match->score." ".$team2;?></strong></a>  </div>
			
		</li>
	<?php
	}
	?>
		</ul>
		
	</div>
</div>
<?php
}
?>

<div class="pager">
<?php
	echo $paging->fetch();
?>
</div>

<?php include_once('includes/footer.php'); 	 ?>